<?php
namespace App\Controller;
use Common\Controller\AppuserbaseController;
use Common\Service\WxpayService;
use Think\Controller;

class CeController extends AppuserbaseController {
    private function test($str,$line_lenght,&$arr=array()){
        $tem_str = mb_substr($str,0,$line_lenght,'utf-8');
        $str = str_replace($tem_str,"",$str);
        for($i=0;$i<$line_lenght;$i++){
            $zi = mb_substr($tem_str,$i,1,'utf-8');
            $arr[$i] = empty($arr[$i]) ? $zi : $arr[$i]." ".$zi;
        }
        if(!empty($str)){
            $this->test($str,$line_lenght,$arr);
        }else{
            return $arr;
        }
    }

    public function ce(){
        $this->display();
/*        die;
        $cities=M('Region')->field('id,name,pid,pid2')->select();
        foreach ($cities as &$city){
            if($city['pid']==0){
                foreach ($cities as $k=>$c){
                    if($c['pid']==$city['id']){
                        $city['city'][]=['id'=>$c['id'],'name'=>$c['name']];
                        unset($cities[$k]);
                    }
                    if($c['pid2']==$city['id']){
                        $city['district'][]=['id'=>$c['id'],'name'=>$c['name']];
                        unset($cities[$k]);
                    }
                }
            }
        }*/
    }
    public function test22(){
        header("Content-type:text/html;charset=utf-8");
        $str="寥落古行宫，<br>宫花寂寞红。<br>白头宫女在，<br>闲坐说玄宗。<br>寥落古行宗，<br>宫花寂寞宗。<br>白头宫女宗，<br>闲坐说玄在。";
        $str=explode('<br>',$str);
//print_r(strlen($str[0])/4+1);
        $str_r=array();
        for($i=0;$i<count($str);$i++)
        {
            for($j=0;$j<mb_strlen($str[$i],'utf-8');$j++)
            {
                $str_r[$i][$j]=mb_substr($str[$i],$j,1,'UTF-8');
            }
        }
        //print_r($str_r);
        for($i=0;$i<6;$i++)
        {
            for($j=0;$j<count($str);$j++)
            {
                print_r($str_r[$j][$i]);
            }
            echo "<br>";
        }
    }
	public function index(){
/*        header("Content-type:text/html;charset=utf-8");
		$str='寥落古行宫，宫花寂寞红。白头宫女在，闲坐说玄宗。';
        $result=[];
        $this->test($str,6,$result);
        foreach ($result as $info){
            echo $info."<br/>";
        }
        die;*/
        //116.298718,39.839075
        header("Content-type:text/html;charset=utf-8");
/*        $result=(new WxpayService(2))->mchPay(sp_get_order_sn(), '1','okB30wk-A2XttDZaMoPCFNJJzrS4','转账');
        var_dump($result);die;*/
       // $beforeOrder=D('Common/Wxpay','Service')->appPay('17071779433554', "订单编号17071779433554", '12');
       // echo date("Y-m-d H:i:s",1501670004);die;
//echo strtotime("2017-07-28 00:00:00");die;
        // var_dump( json_encode([['time'=>'1492365891','price'=>'123','type'=>1,'remark'=>'sadasd'],['time'=>'1492365892','price'=>'124','type'=>1,'remark'=>'sadas2'],['time'=>'1492365893','price'=>'125','type'=>2,'remark'=>'sadas3']]));die;
        //pay ceshi1
        //$url='http://qiche.test2.yikeapp.cn/App/User/submit';

        $url='http://www.qiche.com/App/Businessservice/getBusinessData';
		$data=['lat'=>'39.839086','lng'=>'116.299318','name'=>'an_ceshi','password'=>'123456','sn'=>'17071954820598','type'=>'1','phone'=>'15662165605','account'=>'1342','token'=>'59afaa9d0ae91','page'=>'1','d'=>'ceshi1','image'=>'http://www.qiche.com/data/upload/user/20170616/5943a28bb9a20.png'];
		$r=$this->requestByPost($url,$data);//5942233dd8c39
        echo '<pre>';
		print_r($r);
	}
    public function index2(){
        header("Content-type:text/html;charset=utf-8");
		$url='http://qiche.test2.yikeapp.cn/App/Public/getPhoneCode';
		$data=['phone'=>'15330245125','type'=>'2'];
		$r=$this->requestByPost($url,$data);
		var_dump($r);
	}

}